package com.maple.utils.db

import androidx.room.*
import com.maple.utils.db.User

@Dao
interface UserDao {

    @Insert
    fun insert(obj: User) : Long

    @Query("select * from User")
    fun queryAll(): List<User>?

    @Query("select * from User where id = :id")
    fun queryBy(id: Long): User?

    @Update
    fun update(obj: User)

    @Query("delete from User where id = :id")
    fun delete(id: Long)

    @Query("delete from User")
    fun deleteAll()

    @Query("select * from User limit 1")
    fun queryFirst(): User?

    @Query("select * from User order by id DESC limit 1")
    fun queryLast(): User?
}